import { NextFunction, Response } from "express";
import { LoggedInRequest } from "../types";
import { UserState } from "../dao/UserState";

export const checkUserState = (req: LoggedInRequest, res: Response, next: NextFunction) => {
  const userId = req.userInfo.userId
  
  if (UserState.getInstance().judgeState(userId)) {
    res.status(401).send({
      code: 0,
      msg:'账号已被禁用！'
    })

    return
  } 

  next()
}